package io.gitee.hchaojie.day08.thread;

public class TestCounter {
    public static void main(String[] args) {
        Counter counter = new Counter();
        
//        Thread t1 = new Thread(() -> {
//            counter.increase();
//        });
//        
//        Thread t2 = new Thread(() -> {
//            counter.increase();
//        });
//        
//        t1.start();
//        t2.start();
        
        for (int i = 0; i < 10; i++) {
            Thread t = new Thread(() -> {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                counter.increase(); //
            });
            t.start();
        }

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(counter.getCount());
    }
}
